module.exports = function($scope, $resource, obj, $state, $modalInstance, $modal){

	console.log('place');

	$scope.obj = obj;


	$scope.img = function(){

		var para = $state.get('app.imageupload');
		para.resolve.dir = function(){
            return 'weshop_place';
        };
        para.resolve.xxx = function(){
        	return {
        		'queueLimit' : 1,
        	};
        };
        var modalInstance = $modal.open(para);
        modalInstance.opened.then(function() {// 模态窗口打开之后执行的函数  
        });  
        modalInstance.result.then(function(result) {  
        	console.log(result);
        	if(result.length > 0){
        		console.log($scope.obj);
        		$scope.obj['img'] = result[0];
        	}
        	console.log($scope.obj);
        }, function(reason) {  
            // click，点击取消，则会暑促cancel  
            $log.info('Modal dismissed at: ' + new Date());  
        }); 

	};


	$scope.gogo = function(){

        $resource('/api/ac/wc/productbussinessService/create', {}, {}).save($scope.obj, function (res) {
		//$resource('/api/as/wc/productbussiness/save', {}, {}).save($scope.obj, function (res) {
			console.log(res);

			if (res.errcode !== 0) {
				alert(res.errmsg);
				return;
			}
			alert("保存成功");
			$modalInstance.close();

		});
	};

	$scope.cancel = function(){

		$modalInstance.close();

	}

};
